import { addUserSignInUsingPost } from "@/api/userController";
import { message } from "antd";
import { useEffect, useState } from "react";

/**
 * 添加用户签到记录钩子
 * @param props
 * @constructor
 */
const useAddUserSingInRecord = () => {
  // 加载状态
  const [loading, setLoading] = useState<boolean>(true);

  const year = new Date().getFullYear();
  // 请求后端签到记录
  const doFetch = async () => {
    setLoading(true);
    try {
      await addUserSignInUsingPost({});
    } catch (error) {
      message.error("获取签到记录失败");
    }
    setLoading(false);
  };

  // 只调用一次获取数据
  useEffect(() => {
    doFetch();
  }, []);

  return { loading };
};

export default useAddUserSingInRecord;
